# response_helpers.py
from rest_framework.response import Response


def success(data=None, msg="请求成功"):
	if data is None:
		res = { "code": 20000, "msg": msg }
	else: res = {
		"code": 20000,
		"data": data,
		"msg": msg
	}
	return Response(data=res)

def failure(msg="请求失败", code=50000, data=None):
	res = {
		"code": code,
		"msg": msg,
	}
	if data:
		res["data"] = data
	return Response(data=res)
